package session07.guessnumber;

import javax.swing.*;
import java.awt.*;

public class GameFrame extends JFrame {

    private Container contentP;

    private UpPanel upP;
    private MidPanel midP;
    private DownPanel downP;

    public GameFrame(){
        this.setSize(300,470); //设置宽、高
        Toolkit tk = Toolkit.getDefaultToolkit();
        this.setLocationRelativeTo(null);//传另一个容器就相对于另一个容器，传null就相对于屏幕
        this.setTitle("猜数字游戏");
        this.setIconImage(tk.createImage("img/hp.JPG"));//设置窗体的图片
        this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);//设置关闭窗口即关闭程序
        this.setResizable(false);//设置窗体大小不可变
        this.addContent();

        this.setVisible(true);//设置界面可见，永远放到最后
    }

    private void addContent() {
        this.contentP = this.getContentPane();
        this.contentP.setLayout(new GridLayout(3,1));

        this.upP = new UpPanel();
        this.midP = new MidPanel();
        this.downP = new DownPanel();

        this.contentP.add(this.upP);
        this.contentP.add(this.midP);
        this.contentP.add(this.downP);

    }

}
